Listing 1: Benchmarks

Matrix multiplication

	  program matbench
	  real*8 a(50,50),b(50,50),c(50,50)

	  time = second(0.)
	  do i=1,50
	  	do j=1,50
		a(i,j) = i + j*0.01
		b(i,j) = a(i,j)
		end do
	  end do
	  time = second(0.) - time
	  write (*,*) "Time to set up matrices:",time," seconds"

	  time = second(0.)
	  call mat_mult(c,50,a,50,b,50,50,50,50)
	  time = second(0.) - time
	  write (*,*) "Time to multiply matrices:",time," seconds"
	  
	  pause
	  end
	  
      subroutine mat_mult(c,nc,a,na,b,nb,n1,n2,n3)
c      sets c=a.b; c must be different from a or b
c      na,nb,nc are first dimensions
c      n1 n2 n3 are problem dimensions
c      c is n1xn3
c      a    n1 n2
c      b    n2 n3
      real*8 c(nc,n3),a(na,n2),b(nb,n3)

      do k=1,n3
      	do i = 1,n1
      		c(i,k) = 0d0
      	end do
      	do j=1,n2
      		do i=1,n1
      			c(i,k) = c(i,k)+a(i,j)*b(j,k)
      		end do
      	end do
      end do
      return
      end

      FUNCTION SECOND(X)
      CALL UTILIZ(TIME)
      SECOND=TIME
      RETURN
      END

      SUBROUTINE UTILIZ(TIME)
      TIME = LONG(362)/60.0
      END

Whetstone benchmark

C
      PROGRAM WHETSTONE
      DIMENSION E1(4)
      COMMON /A/ E1,J,K,L
      COMMON /B/ T,T2
C     SYNTHETIC BENCHMARK  BY CURNOW/WICHMANN
C     ***************************************
C     INITIALIZE CONSTANTS
      T=0.499975
      T1=0.50025
      T2=2.0
C     READ VALUE OF I, CONTROLLING TOTAL WEIGHT:
C     IF I=10 THE TOTAL WEIGHT IS ONE MILLION WHETSTONE INSTUCTIONS
C
      I=10
C
      CALL UTILIZ(TT1)
      CPU1=SECOND(Z)
      II=I
      N1=0
      N2=12*I
      N3=14*I
      N4=345*I
      N5=0
      N6=210*I
      N7=32*I
      N8=899*I
      N9=616*I
      N10=0
      N11=93*I
C     MODULE 1: SIMPLE IDENTIFIERS
      JJ=100
99999 CONTINUE
      X1=1.0
      X2=-1.0
      X3=-1.0
      X4=-1.0
      IF (N1) 12,15,12
12    CONTINUE
      DO 10 I=1,N1
      X1=( X1+X2+X3-X4)*T
      X2=( X1+X2-X3+X4)*T
      X3=( X1-X2+X3+X4)*T
      X4=(-X1+X2+X3+X4)*T
10    CONTINUE
X     CALL POUT(N1,N1,N1,X1,X2,X3,X4)
15    CONTINUE
C     MODULE 2: ARRAY ELEMENTS
      E1(1)=1.0
      E1(2)=-1.0
      E1(3)=-1.0
      E1(4)=-1.0
      DO 20 I=1,N2
      E1(1)=( E1(1)+E1(2)+E1(3)-E1(4))*T
      E1(2)=( E1(1)+E1(2)-E1(3)+E1(4))*T
      E1(3)=( E1(1)-E1(2)+E1(3)+E1(4))*T
      E1(4)=(-E1(1)+E1(2)+E1(3)+E1(4))*T
20    CONTINUE
X     CALL POUT(N2,N3,N2,E1(1),E1(2),E1(3),E1(4))
C     MODULE 3: ARRAY AS PARAMETER
      DO 30 I=1,N3
      CALL PA(E1)
30    CONTINUE
X     CALL POUT(N3,N2,N2,E1(1),E1(2),E1(3),E1(4))
C     MODULE 4: CONDITIONAL JUMPS
      J=1
      DO 40 I=1,N4
      IF(J.EQ.1) GOTO 42
41    J=2
      GO TO 43
42    J=3
43    IF(J.GT.2) GOTO 45
44    J=0
      GO TO 46
45    J=1
46    IF(J.LT.1) GOTO 48
47    J=1
      GO TO 40
48    J=0
40    CONTINUE
X     CALL POUT(N4,J,J,X1,X2,X3,X4)
C     MODULE 5: OMITTED
C     MODULE 6: INTEGER ARITHMETIC
      J=1
      K=2
      L=3
      DO 60 I=1,N6
      J=J*(K-J)*(L-K)
      K=L*K-(L-J)*K
      L=(L-K)*(K+J)
      E1(L-1)=J+K+L
      E1(K-1)=J*K*L
60    CONTINUE
X     CALL POUT(N6,J,K,E1(1),E1(2),E1(3),E1(4))
C     MODULE 7: TRIG. FUNCTIONS
      X=0.5
      Y=0.5
      DO 70 I=1,N7
      X=T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0))
      Y=T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0))
70    CONTINUE
X     CALL POUT(N7,J,K,X,X,Y,Y)
C     MODULE 8: PROCEDURE CALLS
      X=1.0
      Y=1.0
      Z=1.0
      DO 80 I=1,N8
      CALL P3(X,Y,Z)
80    CONTINUE
X     CALL POUT(N8,J,K,X,Y,Z,Z)
C     MODULE 9: ARRAY REFERENCES
      J=1
      K=2
      L=3
      E1(1)=1.0
      E1(2)=2.0
      E1(3)=3.0
      DO 90 I=1,N9
      CALL P0
90    CONTINUE
X     CALL POUT(N9,J,K,E1(1),E1(2),E1(3),E1(4))
C     MODULE 10: INTEGER ARITHMETIC
      J=2
      K=3
      IF (N10) 97,105,97
97    CONTINUE
      DO 100 I=1,N10
      J=J+K
      K=J+K
      J=K-J
      K=K-J-J
100   CONTINUE
X     CALL POUT(N10,J,K,X1,X2,X3,X4)
105   CONTINUE
C     MODULE 11: STANDARD FUNCTIONS
      X=0.75
      DO 110 I=1,N11
      X=SQRT(EXP(ALOG(X)/T1))
110   CONTINUE
      JJ=JJ-1
      IF (JJ.GT.0) GOTO 99999
X     CALL POUT(N11,J,K,X,X,X,X)
      CPU2=SECOND(Z)
      CPU2=1000000.0/FLOAT(II)/(CPU2-CPU1)
      WRITE(*,2) CPU2
2     FORMAT(/// " TOTAL WEIGHT:" ,F10.3," (IN THOUSANDS OF WHETSTONE",
     *       " INSTRUCTIONS)")
       CALL UTILIZ(TT2)
       TTT=TT2-TT1
       WRITE(*,7777)TTT
7777   FORMAT(' TIME TAKEN  ',F12.4)
      END
      SUBROUTINE PA(E)
      DIMENSION E(4)
      COMMON /B/ T,T2
      J=0
100   E(1)=( E(1)+E(2)+E(3)-E(4))*T
      E(2)=( E(1)+E(2)-E(3)+E(4))*T
      E(3)=( E(1)-E(2)+E(3)+E(4))*T
      E(3)=(-E(1)+E(2)+E(3)+E(4))/T2
      J=J+1
      IF (J-6) 100,105,105
105   CONTINUE
      RETURN
      END
      SUBROUTINE P0
      DIMENSION E1(4)
      COMMON /A/ E1,J,K,L
      E1(J)=E1(K)
      E1(K)=E1(L)
      E1(L)=E1(J)
      RETURN
      END
      SUBROUTINE P3(X,Y,Z)
      COMMON /B/ T,T2
	  AX=X
      AY=Y
      AX=T*(AX+AY)
      AY=T*(AX+AY)
      Z=(AX+AY)/T2
      RETURN
      END
      SUBROUTINE POUT(N,J,K,X1,X2,X3,X4)
      WRITE(*,4) N
      WRITE(*,4) J
      WRITE(*,4) K
      WRITE(*,3) X1
      WRITE(*,3) X2
      WRITE(*,3) X3
      WRITE(*,3) X3
      WRITE(*,3) X4
3     FORMAT(1X,E25.15)
4     FORMAT(1X,I10)
      RETURN
      END

      FUNCTION SECOND(X)
      CALL UTILIZ(TIME)
      SECOND=TIME
      RETURN
      END

      SUBROUTINE UTILIZ(TIME)
      TIME = LONG(362)/60.0
      END

Listing 2: Assembly listing of inner loops of matrix multiply routine

LS Fortran, no optimization

L10009	EQU	*
 ;  File "matmult.f";  Line         16
		MOVE.L	$FFFFFFF8(A6),D1
		SUB.L	$FFFFFFAC(A6),D1
		ASL.L	#3,D1
		MOVE.L	$FFFFFFF4(A6),D2
		SUB.L	$FFFFFFB8(A6),D2
		MULS.L	$FFFFFFB4(A6),D2
		ADD.L	D1,D2
		MOVE.L	D2,$FFFFFF84(A6)
		MOVE.L	$FFFFFFF8(A6),D1
		SUB.L	$FFFFFFAC(A6),D1
		ASL.L	#3,D1
		MOVE.L	$FFFFFFF4(A6),D2
		SUB.L	$FFFFFFB8(A6),D2
		MULS.L	$FFFFFFB4(A6),D2
		ADD.L	D1,D2
		MOVE.L	D2,$FFFFFF68(A6)
		MOVE.L	$FFFFFFF8(A6),D1
		SUB.L	$FFFFFFC4(A6),D1
		ASL.L	#3,D1
		MOVE.L	$FFFFFFFC(A6),D2
		SUB.L	$FFFFFFD0(A6),D2
		MULS.L	$FFFFFFCC(A6),D2
		ADD.L	D1,D2
		MOVE.L	D2,$FFFFFF6C(A6)
		MOVE.L	$FFFFFFFC(A6),D1
		SUB.L	$FFFFFFDC(A6),D1
		ASL.L	#3,D1
		MOVE.L	$FFFFFFF4(A6),D2
		SUB.L	$FFFFFFE8(A6),D2
		MULS.L	$FFFFFFE4(A6),D2
		ADD.L	D1,D2
		MOVE.L	D2,$FFFFFF70(A6)
		MOVEA.L	$0020(A6),A0
		ADDA.L	$FFFFFF6C(A6),A0
		FMOVE.D	(A0),FP7
		MOVEA.L	$0018(A6),A1
		ADDA.L	$FFFFFF70(A6),A1
		FMUL.D	(A1),FP7
		MOVEA.L	$0028(A6),A1
		ADDA.L	$FFFFFF68(A6),A1
		FADD.D	(A1),FP7
		MOVEA.L	$0028(A6),A1
		ADDA.L	$FFFFFF84(A6),A1
		FMOVE.D	FP7,(A1)
 ;  File "matmult.f";  Line         17
		ADDQ.L	#1,$FFFFFFF8(A6)
		SUBQ.L	#1,D7
		BGT		L10009

LS Fortran, -opt=3 optimization

L10009	EQU	*
 ;  File "matmult.f";  Line         16
		MOVE.L	$FFFFFF5C(A6),$FFFFFF58(A6)
		MOVE.L	$FFFFFF64(A6),$FFFFFF40(A6)
		MOVEA.L	$0020(A6),A0
		ADDA.L	$FFFFFF60(A6),A0
		FMOVE.D	(A0),FP7
		MOVEA.L	$0018(A6),A1
		ADDA.L	$FFFFFF40(A6),A1
		FMUL.D	(A1),FP7
		MOVEA.L	$0028(A6),A1
		ADDA.L	$FFFFFF58(A6),A1
		FADD.D	(A1),FP7
		FMOVE.D	FP7,(A1)
 ;  File "matmult.f";  Line         17
		MOVEQ	#$0008,D1
		ADD.L	D1,$FFFFFF5C(A6)
		ADD.L	D1,$FFFFFF60(A6)
		ADDQ.L	#1,$FFFFFFF8(A6)
		SUBQ.L	#1,D7
		BGT.S	L10009

Absoft Fortran, no optimization

L14:

;                c(i,k) = c(i,k)+a(i,j)*b(j,k)

	move.l		d3,d2
	sub.l		#$0001,d2
	move.l		(20,a7),d4
	move.l		d4,d6
	sub.l		#$0001,d6
	move.l		(a7),d0
	muls.l		d0,d6
	add.l		d6,d2
	move.l		d3,d6
	sub.l		#$0001,d6
	move.l		(36,a7),d5
	move.l		d5,d7
	sub.l		#$0001,d7
	muls.l		(8,a7),d7
	add.l		d7,d6
	sub.l		#$0001,d5
	move.l		d4,d7
	sub.l		#$0001,d7
	muls.l		(16,a7),d7
	add.l		d7,d5
	move.l		(200,a7),a2
	fmove.d		(a2,d6.l*8),fp2
	move.l		(208,a7),a3
	fmove.d		(a3,d5.l*8),fp3
	fmul.x		fp3,fp2
	move.l		(192,a7),a4
	fmove.d		(a4,d2.l*8),fp4
	fadd.x		fp2,fp4
	move.l		d3,d2
	sub.l		#$0001,d2
	move.l		d4,d5
	sub.l		#$0001,d5
	muls.l		d0,d5
	add.l		d5,d2
	fmove.d		fp4,(a4,d2.l*8)
	add.l		#$0001,d3
	move.l		(44,a7),d6
	move.l		d6,d7
	sub.l		#$0001,d7

;            end do

	move.l		d7,(44,a7)
;  loop bottom branch
	tst.l		d7
	bgt		L14

Absoft Fortran, -O optimization

L14:
	move.l		d6,d7
	sub.l		#$0001,d7
	move.l		d7,d2
	add.l		(236,a7),d2
	add.l		(240,a7),d7
	fmove.d		(a2,d7.l*8),fp2
	fmul.d		(248,a7),fp2
	fmove.d		(a3,d2.l*8),fp3
	fadd.x		fp2,fp3
	fmove.d		fp3,(a3,d2.l*8)
	add.l		#$0001,d6
	sub.l		#$0001,d4

;            end do

	tst.l		d4
	bgt		L14

Absoft Fortran, -O -U optimization

L27:
	move.l		d4,d2
	sub.l		#$0001,d2
	move.l		d2,d7
	add.l		d3,d7
	add.l		d0,d2
	fmove.d		(a2,d2.l*8),fp2
	fmul.x		fp3,fp2
	fmove.d		(a3,d7.l*8),fp4
	fadd.x		fp2,fp4
	fmove.d		fp4,(a3,d7.l*8)
	move.l		d4,d2
	add.l		#$0001,d2
	move.l		d2,d4
	sub.l		#$0001,d4
	move.l		d4,d7
	add.l		d3,d7
	add.l		d0,d4
	fmove.d		(a2,d4.l*8),fp5
	fmul.x		fp3,fp5
	fmove.d		(a3,d7.l*8),fp6
	fadd.x		fp5,fp6
	fmove.d		fp6,(a3,d7.l*8)
	move.l		d2,d4
	add.l		#$0001,d4
	sub.l		#$0002,d6

;            end do

	tst.l		d6
	bgt		L27
	move.l		d4,(28,a7)

Absoft Fortran, -O -h4 optimization

L27:
	move.l		d4,d2
	sub.l		#$0001,d2
	move.l		d2,d7
	add.l		d3,d7
	add.l		d0,d2
	fmove.d		(a2,d2.l*8),fp2
	fmul.x		fp3,fp2
	fmove.d		(a3,d7.l*8),fp4
	fadd.x		fp2,fp4
	fmove.d		fp4,(a3,d7.l*8)
	move.l		d4,d2
	add.l		#$0001,d2
	move.l		d2,d4
	sub.l		#$0001,d4
	move.l		d4,d7
	add.l		d3,d7
	add.l		d0,d4
	fmove.d		(a2,d4.l*8),fp5
	fmul.x		fp3,fp5
	fmove.d		(a3,d7.l*8),fp6
	fadd.x		fp5,fp6
	fmove.d		fp6,(a3,d7.l*8)
	add.l		#$0001,d2
	move.l		d2,d4
	sub.l		#$0001,d4
	move.l		d4,d7
	add.l		d3,d7
	add.l		d0,d4
	fmove.d		(a2,d4.l*8),fp7
	fmul.x		fp3,fp7
	fmove.d		(a3,d7.l*8),fp0
	fadd.x		fp7,fp0
	fmove.d		fp0,(a3,d7.l*8)
	add.l		#$0001,d2
	move.l		d2,d4
	sub.l		#$0001,d4
	move.l		d4,d7
	add.l		d3,d7
	add.l		d0,d4
	fmove.d		(a2,d4.l*8),fp2
	fmul.x		fp3,fp2
	fmove.d		(a3,d7.l*8),fp1
	fadd.x		fp2,fp1
	fmove.d		fp1,(a3,d7.l*8)
	move.l		d2,d4
	add.l		#$0001,d4
	sub.l		#$0004,d6

;            end do

	tst.l		d6
	bgt		L27
